'''
Test generator for verifying identifiers
'''

import random
from os.path import basename, dirname, join, pardir
from utils.cj_identifiers import get_all_dollar_identifiers

RND_SEED = 1
random.seed(RND_SEED)
ouput_path = join(dirname(__file__), pardir, '01_lexical_grammar', '06_identifiers', 'a02')

test_char_template = '''# Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
# This source file is part of the Cangjie project, licensed under Apache-2.0
# with Runtime Library Exception.
# 
# See https://cangjie-lang.cn/pages/LICENSE for license information.

/*
  @Name:        A_01_06_a02_01
  @Assertion:   A.1.6(2)
                DollarIdentifier
                    : '$' Identifier
                    ;

  @Description: Check various dollar identifiers
  @Comment:     Auto-generated tests by SCRIPT_NAME with seed = SEED
  @Mode:        run
  @Negative:    no
  @Structure:   single
*/
from std import ast.*

main() {
  CODE
  return 0
}
'''
code_line = '''
    // Check ID2 symbol as dollar identifier
    var ID1 = 42
    quote(ID2)
'''
test_char_template = test_char_template.replace('SCRIPT_NAME', basename(__file__))
test_char_template = test_char_template.replace('SEED', str(RND_SEED))

code_text = ''
for id1 in get_all_dollar_identifiers(max_num=50):
    code_text += code_line.replace('ID1', id1.value[1:]).replace('ID2', id1.value)

test_text = test_char_template.replace('CODE', code_text)

with open(join(ouput_path, 'test_a02_01.cj'), 'w', encoding='utf-8') as f:
    f.write(test_text)
